diff --git a/group/autogroup.php b/group/autogroup.php
index <HASH>..<HASH> 100644
--- a/group/autogroup.php
+++ b/group/autogroup.php
@@ -42,7 +42,6 @@ if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
 require_login($course);
 
 $context       = context_course::instance($courseid);
-$systemcontext = context_system::instance();
 require_capability('moodle/course:managegroups', $context);
 
 $returnurl = $CFG->wwwroot.'/group/index.php?id='.$course->id;
diff --git a/message/edit.php b/message/edit.php
index <HASH>..<HASH> 100644
--- a/message/edit.php
+++ b/message/edit.php
@@ -61,7 +61,6 @@ if (!$user = $DB->get_record('user', array('id' => $userid))) {
 
 $systemcontext   = context_system::instance();
 $personalcontext = context_user::instance($user->id);
-$coursecontext   = context_course::instance($course->id);
 
 $PAGE->set_context($personalcontext);
 $PAGE->set_pagelayout('course');
MDL-<I> libraries: Remove unused context calls