diff --git a/vpl.class.php b/vpl.class.php
index 58326c8487d13b1970ab59a68471d5ee006b91b8..f7e5af222f2dcf49eb6ca4dccb1eab8f42acb512 100644
--- a/vpl.class.php
+++ b/vpl.class.php
@@ -142,7 +142,7 @@ class mod_vpl {
     /**
      * Internal var array of object to  file group manager
      *
-     * @var araay of object of file group manager
+     * @var array of object of file group manager
      */
     protected $requiredfgm;
 
@@ -162,7 +162,6 @@ class mod_vpl {
      *            optional module instance id
      */
     public function __construct($id, $a = null) {
-        global $OUTPUT;
         global $DB;
         if ($id) {
             if (! $this->cm = get_coursemodule_from_id( VPL, $id )) {
@@ -437,7 +436,7 @@ class mod_vpl {
         // Sort comments by number of occurrences.
         krsort( $all );
         $html = '';
-        foreach ($all as $count => $info) {
+        foreach ($all as $info) {
             $html .= $info;
         }
         // TODO show info about others review with show hidde button.
@@ -536,7 +535,6 @@ class mod_vpl {
      * @return void
      */
     public function network_check() {
-        global $OUTPUT;
         if (! $this->pass_network_check()) {
             $str = get_string( 'opnotallowfromclient', VPL ) . ' ' . getremoteaddr();
             if ( constant( 'AJAX_SCRIPT') ) {
@@ -1040,7 +1038,6 @@ class mod_vpl {
      * @return bool
      */
     public function is_group_activity() {
-        global $CFG;
         if (! isset( $this->group_activity )) {
             $cm = $this->get_course_module();
             $this->group_activity = $cm->groupingid > 0 && $this->get_instance()->worktype == 1;
@@ -1270,7 +1267,7 @@ class mod_vpl {
      * @return Object or false
      */
     public function get_grade_info() {
-        global $DB, $CFG, $USER;
+        global $CFG, $USER;
         if (! isset( $this->grade_info )) {
             $this->grade_info = false;
             if ($this->get_instance()->grade != 0) { // If 0 then NO GRADE.
@@ -1292,7 +1289,6 @@ class mod_vpl {
      * @return boolean
      */
     public function get_visiblegrade() {
-        global $USER;
         if ($gi = $this->get_grade_info()) {
             if (is_array( $gi->grades )) {
                 $usergi = reset( $gi->grades );
@@ -1384,7 +1380,7 @@ class mod_vpl {
      * @param $info string title and last nav option
      */
     public function print_header($info = '') {
-        global $COURSE, $PAGE, $OUTPUT;
+        global $PAGE, $OUTPUT;
         if (self::$headerisout) {
             return;
         }
@@ -1441,7 +1437,7 @@ class mod_vpl {
      */
     public function print_view_tabs($path) {
         // TODO refactor using functions.
-        global $USER, $DB, $OUTPUT, $PAGE;
+        global $USER, $DB, $PAGE;
         $active = basename( $path );
         $cmid = $this->cm->id;
         $userid = optional_param( 'userid', null, PARAM_INT );
@@ -1527,11 +1523,7 @@ class mod_vpl {
             case 'submissionview.php' :
             case 'gradesubmission.php' :
             case 'previoussubmissionslist.php' :
-                require_once('vpl_submission.class.php');
                 $subinstance = $this->last_user_submission( $userid );
-                if ($subinstance !== false) {
-                    $submission = new mod_vpl_submission( $this, $subinstance );
-                }
                 if ($viewer && ! $level2) {
                     $tabs [] = $viewtab;
                 }
@@ -1544,9 +1536,6 @@ class mod_vpl {
                 if ($manager || ($grader && $USER->id == $userid)
                     || (! $grader && $submiter && $this->is_submit_able())) {
                     $href = vpl_mod_href( 'forms/edit.php', 'id', $cmid, 'userid', $userid );
-                    if ($example && $this->instance->run) {
-                        $stredit = get_string( 'run', VPL );
-                    }
                     $tabs [] = vpl_create_tabobject( 'edit.php', $href, 'edit');
                 }
                 if (! $example && $submiter) {
@@ -1561,7 +1550,6 @@ class mod_vpl {
                         $tabs [] = vpl_create_tabobject( 'gradesubmission.php', $href, 'grade', 'moodle' );
                     }
                     if ($subinstance /*&& ($grader || $similarity|| $this->instance->allowshowprevious)*/) {
-                        $strlistprevoiussubmissions = get_string( 'previoussubmissionslist', VPL );
                         $href = vpl_mod_href( 'views/previoussubmissionslist.php', 'id', $cmid, 'userid', $userid );
                         $tabs [] = vpl_create_tabobject( 'previoussubmissionslist.php', $href, 'previoussubmissionslist' );
                     }
@@ -1602,17 +1590,14 @@ class mod_vpl {
             case 'listsimilarity.php' :
                 if ($similarity) {
                     $href = vpl_mod_href( 'similarity/similarity_form.php', 'id', $cmid );
-                    $string = get_string( 'similarity', VPL );
                     $tabs [] = vpl_create_tabobject( 'similarity_form.php', $href, 'similarity' );
                     if ($active == 'listsimilarity.php') {
-                        $string = get_string( 'listsimilarity', VPL );
                         $tabs [] = vpl_create_tabobject( 'listsimilarity.php', '', 'listsimilarity' );
                     }
                     $plugincfg = get_config('mod_vpl');
                     $watermark = isset( $plugincfg->use_watermarks ) && $plugincfg->use_watermarks;
                     if ($watermark) {
                         $href = vpl_mod_href( 'similarity/listwatermark.php', 'id', $cmid );
-                        $string = get_string( 'listwatermarks', VPL );
                         $tabs [] = vpl_create_tabobject( 'listwatermark.php', $href, 'listwatermarks' );
                     }
                 }
@@ -1721,13 +1706,13 @@ class mod_vpl {
         } else {
             $this->print_restriction( 'worktype', $values [$worktype] );
         }
+        $stryes = get_string( 'yes' );
+        $strno = get_string( 'no' );
         if ($instance->example) {
             $this->print_restriction( 'isexample', $stryes );
         }
         $grader = $this->has_capability( VPL_GRADE_CAPABILITY );
         if ($grader) {
-            $stryes = get_string( 'yes' );
-            $strno = get_string( 'no' );
             require_once($CFG->libdir . '/gradelib.php');
             if ($gie = $this->get_grade_info()) {
                 if ($gie->scaleid == 0) {
diff --git a/vpl_submission.class.php b/vpl_submission.class.php
index 492c4a9804ecd9fc29842db6670742b71303fc1c..41cb646535cb0e6a84ac01a71d90b520113e5b0d 100644
--- a/vpl_submission.class.php
+++ b/vpl_submission.class.php
@@ -37,6 +37,7 @@ defined('MOODLE_INTERNAL') || die();
 require_once(dirname(__FILE__).'/vpl.class.php');
 require_once(dirname(__FILE__).'/views/sh_factory.class.php');
 require_once(dirname(__FILE__).'/views/show_hide_div.class.php');
+global $CFG;
 require_once($CFG->dirroot . '/grade/grading/lib.php');
 
 // Non static due to usort error.