diff --git a/ajax.php b/ajax.php
index e0651400de76b172d163ee07e84200fe09b24b2d..f3cc2988510882b284aae4727d7eb8a02a102e80 100644
--- a/ajax.php
+++ b/ajax.php
@@ -350,7 +350,7 @@ switch($action) {
         break;
 
     case 'contenthubregistration':
-        // Check permission
+        // Check permission.
         $context = \context_system::instance();
         if (!has_capability('mod/hvp:contenthubregistration', $context)) {
             \H5PCore::ajaxError(get_string('contenthub:nopermissions', 'hvp'), 'NO_PERMISSION', 403);
@@ -433,12 +433,12 @@ switch($action) {
             'age'                  => optional_param('age', null, PARAM_RAW),
         );
 
-        // Load content
+        // Load content.
         $core = \mod_hvp\framework::instance();
         $cm = get_coursemodule_from_id('hvp', $id);
         $content = $core->loadContent($cm->instance);
 
-        // Update Hub status for content before proceeding
+        // Update Hub status for content before proceeding.
         $newstate = hvp_update_hub_status($content);
         $synced = $newstate !== false ? $newstate : intval($content['synced']);
 
@@ -447,10 +447,10 @@ switch($action) {
             break;
         }
 
-        // Create URL
+        // Create URL.
         $data['download_url'] = hvp_create_hub_export_url($cm->id, $content);
 
-        // Get file size
+        // Get file size.
         $slug = $content['slug'] ? $content['slug'] . '-' : '';
         $filecontext = context_course::instance($cm->course);
         $file = get_file_storage()->get_file($filecontext->id, 'mod_hvp', 'exports', 0, '/', "{$slug}{$content['id']}.h5p");
@@ -461,7 +461,7 @@ switch($action) {
         $size = $file->get_filesize();
         $data['size'] = empty($size) ? -1 : $size;
 
-        // Add the icon and any screenshots
+        // Add the icon and any screenshots.
         $files = array(
             'icon' => !empty($_FILES['icon']) ? $_FILES['icon'] : null,
             'screenshots' => !empty($_FILES['screenshots']) ? $_FILES['screenshots'] : null,
@@ -471,13 +471,13 @@ switch($action) {
             $isedit = !empty($content['contentHubId']);
             $updatecontent = $synced === \H5PContentHubSyncStatus::NOT_SYNCED && $isedit;
             if ($updatecontent) {
-                // node has been edited since the last time it was published
+                // Node has been edited since the last time it was published.
                 $data['resync'] = 1;
             }
             $result = $core->hubPublishContent($data, $files, $isedit ? $content['contentHubId'] : null);
 
             $fields = array(
-                'shared' => 1, // Content is always shared after sharing or editing
+                'shared' => 1, // Content is always shared after sharing or editing.
             );
             if (!$isedit) {
                 $fields['hub_id'] = $result->content->id;
@@ -487,7 +487,7 @@ switch($action) {
                 $fields['synced'] = \H5PContentHubSyncStatus::WAITING;
             }
 
-            // Store the content hub id
+            // Store the content hub id.
             $core->h5pF->updateContentFields($cm->instance, $fields);
 
             H5PCore::ajaxSuccess();
diff --git a/classes/admin_setting_html.php b/classes/admin_setting_html.php
index 48fe941eed68953630768a17e0d76dc694fed233..b789e8aba0958952582aca82bc7a178c3942fd69 100644
--- a/classes/admin_setting_html.php
+++ b/classes/admin_setting_html.php
@@ -56,7 +56,7 @@ class admin_setting_html extends admin_setting {
      * @return string Always returns an empty string
      */
     public function write_setting($data) {
-        // do not write any setting
+        // Do not write any setting.
         return '';
     }
 
diff --git a/classes/framework.php b/classes/framework.php
index 44204df2f59609b99c26ed3ce6e9d927d0a90758..7584827ee1c3b1a62f419a31ded61f66ca6d971a 100644
--- a/classes/framework.php
+++ b/classes/framework.php
@@ -171,7 +171,7 @@ class framework implements \H5PFrameworkInterface {
             $curldata = array();
             foreach ($data as $key => $value) {
                 if (empty($value)) {
-                    continue; // Skip empty values
+                    continue; // Skip empty values.
                 }
                 if (is_array($value)) {
                     foreach ($value as $i => $subvalue) {
@@ -186,17 +186,17 @@ class framework implements \H5PFrameworkInterface {
                 if ($file === null) {
                     continue;
                 } else if (is_array($file['name'])) {
-                    // Array of files uploaded (multiple)
+                    // Array of files uploaded (multiple).
                     for ($i = 0; $i < count($file['name']); $i ++) {
                         $curldata["{$name}[{$i}]"] = new \CurlFile($file['tmp_name'][$i], $file['type'][$i], $file['name'][$i]);
                     }
                 } else {
-                    // Single file
+                    // Single file.
                     $curldata[$name] = new \CurlFile($file['tmp_name'], $file['type'], $file['name']);
                 }
             }
         } else if (!empty($data)) {
-            // application/x-www-form-urlencoded
+            // Application/x-www-form-urlencoded.
             $curldata = format_postdata_for_curlcall($data);
         }
 
@@ -248,7 +248,7 @@ class framework implements \H5PFrameworkInterface {
         }
 
         $errorno = $curl->get_errno();
-        // Error handling
+        // Error handling.
         if ($errorno) {
             if ($alldata) {
                 $response = null;
@@ -1854,7 +1854,7 @@ class framework implements \H5PFrameworkInterface {
     public function replaceContentHubMetadataCache($metadata, $lang = 'en') {
         global $DB;
 
-        // Check if exist in database
+        // Check if exist in database.
         $cache = $DB->get_record_sql(
             'SELECT id
                    FROM {hvp_content_hub_cache}
@@ -1862,10 +1862,10 @@ class framework implements \H5PFrameworkInterface {
             array($lang)
         );
         if ($cache) {
-            // Update
+            // Update.
             $DB->execute("UPDATE {hvp_content_hub_cache} SET json = ? WHERE id = ?", array($metadata, $cache->id));
         } else {
-            // Insert
+            // Insert.
             $DB->insert_record('hvp_content_hub_cache', (object) array(
                 'json'         => $metadata,
                 'language'     => $lang,
diff --git a/db/access.php b/db/access.php
index e017aeacf684a8aae98247a55f2d2a87739ac99d..397bd92654785c206f488e56394632553f8cf638 100644
--- a/db/access.php
+++ b/db/access.php
@@ -201,7 +201,7 @@ $capabilities = array(
     'mod/hvp:contenthubregistration' => [
         'captype' => 'write',
         'contextlevel' => CONTEXT_SYSTEM,
-        'archetypes' => [], // only admins by default
+        'archetypes' => [], // Only admins by default.
     ],
 
 );
diff --git a/db/upgrade.php b/db/upgrade.php
index d0791300476e4b3797c4b47ca117db9eb1f49c9c..dee0096d5c1f4e42e5cfbd690eb874fceed62ca2 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -524,21 +524,21 @@ function hvp_upgrade_2020082800() {
  * Drop old unused unique index, add nonunique index.
  */
 function hvp_upgrade_2020091500() {
-  global $DB;
-  $dbman = $DB->get_manager();
-  $table = new xmldb_table('hvp_xapi_results');
-  $index = new xmldb_index('results', XMLDB_INDEX_NOTUNIQUE, ['content_id', 'user_id']);
-  $dbman->add_index($table, $index);
-
-  $oldindex = new xmldb_index('result', XMLDB_INDEX_UNIQUE, ['id', 'content_id', 'user_id']);
-  $dbman->drop_index($table, $oldindex);
+      global $DB;
+      $dbman = $DB->get_manager();
+      $table = new xmldb_table('hvp_xapi_results');
+      $index = new xmldb_index('results', XMLDB_INDEX_NOTUNIQUE, ['content_id', 'user_id']);
+      $dbman->add_index($table, $index);
+
+      $oldindex = new xmldb_index('result', XMLDB_INDEX_UNIQUE, ['id', 'content_id', 'user_id']);
+      $dbman->drop_index($table, $oldindex);
 }
 
 function hvp_upgrade_2020112600() {
     global $DB;
     $dbman = $DB->get_manager();
 
-    // Add Content Hub fields to main content table
+    // Add Content Hub fields to main content table.
     $table = new xmldb_table('hvp');
     if (!$dbman->field_exists($table, 'shared')) {
         $dbman->add_field($table, new xmldb_field('shared', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, 'completionpass'));
@@ -550,7 +550,7 @@ function hvp_upgrade_2020112600() {
         $dbman->add_field($table, new xmldb_field('hub_id', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'synced'));
     }
 
-    // Create table for caching content hub metadata
+    // Create table for caching content hub metadata.
     $table = new xmldb_table('hvp_content_hub_cache');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('language', XMLDB_TYPE_CHAR, '31', null, XMLDB_NOTNULL, null, null);
diff --git a/lang/en/hvp.php b/lang/en/hvp.php
index da28414a2d8861b6b56be6a50cefed2c66e45908..5eed2a104a27b8b8b8800416d59507fcc401e138 100644
--- a/lang/en/hvp.php
+++ b/lang/en/hvp.php
@@ -483,7 +483,7 @@ $string['gradetopassmustbeset'] = 'Grade to pass cannot be zero as this H5P acti
 $string['gradeheading'] = 'Results for {$a}';
 $string['assistivetechnologieslabel'] = 'Assistive Technologies label';
 
-// Content hub
+// Content hub.
 $string['contenthub:settings:heading'] = 'H5P Hub Account Settings';
 $string['contenthub:settings:box'] = 'Content Hub Account';
 $string['contenthub:licenseagreementtitle'] = 'End User License Agreement (EULA)';
@@ -588,7 +588,7 @@ $string['add'] = 'Add';
 $string['updateregistrationonhub'] = 'Save account settings';
 $string['successfullyupdated'] = 'Your H5P Hub account settings have successfully been changed';
 
-# Content hub
+// Content hub.
 $string['age'] = 'Typical age';
 $string['agedescription'] = 'The target audience of this content. Possible input formats separated by commas: "1,34-45,-50,59-".';
 $string['invalidage'] = 'Invalid input format for Typical age. Possible input formats separated by commas: "1, 34-45, -50, -59-".';
diff --git a/lib.php b/lib.php
index 3752cdf688688a38e47f0fcb3d80b033589caca1..c16286dbe9122c2eae0014afdb80464911a43450 100644
--- a/lib.php
+++ b/lib.php
@@ -213,7 +213,7 @@ function hvp_delete_instance($id) {
             array($hvp->main_library_id)
     );
 
-    // Only log event if we found library
+    // Only log event if we found library.
     if ($library) {
         // Log content delete.
         new \mod_hvp\event(
@@ -293,7 +293,7 @@ function hvp_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload
                 return false; // Invalid context.
             }
 
-            // Allow download if valid temporary hash
+            // Allow download if valid temporary hash.
             $ishub = false;
             $hub = optional_param('hub', null, PARAM_RAW);
             if ($hub) {
@@ -305,12 +305,11 @@ function hvp_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload
                 $signature = hash_hmac('SHA512', $data, get_config('mod_hvp', 'hub_secret'), true);
 
                 if ($time < (time() - 43200) || !hash_equals($signature, $hash)) {
-                    // No valid hash
+                    // No valid hash.
                     return false;
                 }
                 $ishub = true;
-            }
-            elseif (!has_capability('mod/hvp:view', $context)) {
+            } else if (!has_capability('mod/hvp:view', $context)) {
                 // No permission.
                 return false;
             }
diff --git a/locallib.php b/locallib.php
index 59ba6e1fcc3fff8a1e842a8b88ff59e7933a345d..874d1aed2245fbf23c5aa20e44cb06f4b8272bce 100644
--- a/locallib.php
+++ b/locallib.php
@@ -670,21 +670,22 @@ function hvp_attempt_submitted_handler($event) {
  * @param $content
  */
 function hvp_update_hub_status($content) {
-  $synced = intval($content['synced']);
+    $synced = intval($content['synced']);
 
-  // Only check sync status when waiting
-  if (empty($content['contentHubId']) || $synced !== H5PContentHubSyncStatus::WAITING) {
-      return false;
-  }
+    // Only check sync status when waiting.
+    if (empty($content['contentHubId']) || $synced !== H5PContentHubSyncStatus::WAITING) {
+        return false;
+    }
 
-  $core = \mod_hvp\framework::instance();
-  $newstate = $core->getHubContentStatus($content['contentHubId'], $synced);
-  if ($newstate !== false) {
-      $core->h5pF->updateContentFields($content['id'], array('synced' => $newstate));
-      return $newstate;
-  }
+    $core = \mod_hvp\framework::instance();
+    $newstate = $core->getHubContentStatus($content['contentHubId'], $synced);
+    if ($newstate !== false) {
+        $core->h5pF->updateContentFields($content['id'], array('synced' => $newstate));
 
-  return false;
+        return $newstate;
+    }
+
+    return false;
 }
 
 /**
@@ -693,25 +694,27 @@ function hvp_update_hub_status($content) {
  * @param $content
  */
 function hvp_create_hub_export_url($cmid, $content) {
-  // Create URL
-  $modulecontext = \context_module::instance($cmid);
-  $slug = $content['slug'] ? $content['slug'] . '-' : '';
-  $filename = "{$slug}{$content['id']}.h5p";
-  $exporturl = \moodle_url::make_pluginfile_url($modulecontext->id, 'mod_hvp', 'exports', '', '', $filename)->out(false);
-
-  // To prevent anyone else from downloading we add an extra token
-  $time = time();
-  $data = $time . ':' . get_config('mod_hvp', 'site_uuid');
-  $hash = hash_hmac('SHA512', $data, get_config('mod_hvp', 'hub_secret'), true);
-  $token = hvp_base64_encode($time) . '.' . hvp_base64_encode($hash);
-
-  return "$exporturl?hub=$token";
+    // Create URL.
+    $modulecontext = \context_module::instance($cmid);
+    $slug          = $content['slug'] ? $content['slug'] . '-' : '';
+    $filename      = "{$slug}{$content['id']}.h5p";
+    $exporturl     = \moodle_url::make_pluginfile_url($modulecontext->id, 'mod_hvp', 'exports', '', '', $filename)
+        ->out(false);
+
+    // To prevent anyone else from downloading we add an extra token.
+    $time  = time();
+    $data  = $time . ':' . get_config('mod_hvp', 'site_uuid');
+    $hash  = hash_hmac('SHA512', $data, get_config('mod_hvp', 'hub_secret'), true);
+    $token = hvp_base64_encode($time) . '.' . hvp_base64_encode($hash);
+
+    return "$exporturl?hub=$token";
 }
 
 /**
  * URL compatible base64 encoding.
  *
- * @param string $string
+ * @param  string  $string
+ *
  * @return string
  */
 function hvp_base64_encode($string) {
diff --git a/mod_form.php b/mod_form.php
index b21a428e3f82f81931fd10a705553de6aace7d81..a7d89767e05ea599a493c8771ecf54f0add292ae 100644
--- a/mod_form.php
+++ b/mod_form.php
@@ -361,13 +361,13 @@ class mod_hvp_mod_form extends moodleform_mod {
     public function data_postprocessing($data) {
         // Determine disabled content features.
 
-        // mod_form may be loaded without the H5P editor, so we have to check if
+        // Mod_form may be loaded without the H5P editor, so we have to check if
         // data is present if we want to process them.
-        $hasDisplayOptions = isset($data->frame)
+        $hasdisplayoptions = isset($data->frame)
             || isset($data->export)
             || isset($data->embed)
             || isset($data->copyright);
-        if ($hasDisplayOptions) {
+        if ($hasdisplayoptions) {
             $options = array(
                 \H5PCore::DISPLAY_OPTION_FRAME     => isset($data->frame) ? $data->frame : 0,
                 \H5PCore::DISPLAY_OPTION_DOWNLOAD  => isset($data->export) ? $data->export : 0,
diff --git a/settings.php b/settings.php
index 04c4a44990d7f19bc864342b8b4c173740094fa8..00e764795eda59df06686bbe0b03c131ad6cadd7 100644
--- a/settings.php
+++ b/settings.php
@@ -112,7 +112,7 @@ if ($ADMIN->fulltree) {
         )
     );
 
-    // Content Hub
+    // Content Hub.
     $hubinfo = $core->hubAccountInfo();
     $settings->add(new admin_setting_heading(
         'mod_hvp/content_hub_settings',
diff --git a/share.php b/share.php
index ce23bc0bd00beb834414a9198fab3fbf825a19ff..186b37865a1c624751f5be8bd2e9f86578c8d943 100644
--- a/share.php
+++ b/share.php
@@ -40,7 +40,7 @@ require_course_login($course, true, $cm);
 $context = context_module::instance($cm->id);
 require_capability('mod/hvp:share', $context);
 
-// Check if Hub registered, if not redirect to hub registration
+// Check if Hub registered, if not redirect to hub registration.
 if (empty(get_config('mod_hvp', 'site_uuid')) || empty(get_config('mod_hvp', 'hub_secret'))) {
     if (!has_capability('mod/hvp:contenthubregistration', \context_system::instance())) {
         print_error('nohubregistration');
@@ -48,13 +48,13 @@ if (empty(get_config('mod_hvp', 'site_uuid')) || empty(get_config('mod_hvp', 'hu
     redirect(new moodle_url('/mod/hvp/content_hub_registration.php'));
 }
 
-// Try to load existing content from the Hub
+// Try to load existing content from the Hub.
 $core    = \mod_hvp\framework::instance();
 $content = $core->loadContent($cm->instance);
 
 $action = optional_param('action', '', PARAM_TEXT);
 if ($action) {
-    // Prepare to do a Hub Action
+    // Prepare to do a Hub Action.
     if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
         http_response_code(405);
     }
@@ -68,13 +68,13 @@ if ($action) {
 
     $core = \mod_hvp\framework::instance();
     if ($action === 'sync') {
-        // Sync content already shared on the Hub
+        // Sync content already shared on the Hub.
         $exporturl = hvp_create_hub_export_url($cm->id, $content);
         if ($core->hubSyncContent($content['contentHubId'], $exporturl)) {
             $core->h5pF->updateContentFields($content['id'], array('synced' => \H5PContentHubSyncStatus::WAITING));
         }
     } else if ($action === 'unpublish') {
-        // Unpublish content already shared on the Hub
+        // Unpublish content already shared on the Hub.
         if ($core->hubUnpublishContent($content['contentHubId'])) {
             $core->h5pF->updateContentFields($content['id'], array('shared' => 0));
         }
@@ -85,7 +85,7 @@ if ($action) {
 
 $hubcontent = !empty($content['contentHubId']) ? $core->hubRetrieveContent($content['contentHubId']) : null;
 if (empty($content['contentHubId'])) {
-    // Try to populate with license from content
+    // Try to populate with license from content.
     $license        = !empty($content['metadata']['license']) ? $content['metadata']['license'] : null;
     $licenseversion = !empty($license) && !empty($content['metadata']['licenseVersion']) ? $content['metadata']['licenseVersion'] : null;
     $showcopyrightwarning = false;
@@ -106,7 +106,7 @@ if (empty($content['contentHubId'])) {
     ];
 }
 
-// Prepare settings for the UI
+// Prepare settings for the UI.
 $locale   = \mod_hvp\framework::get_language();
 $settings = [
     'token'       => \H5PCore::createToken('share_' . $id),
@@ -126,7 +126,7 @@ $PAGE->set_url(new \moodle_url('/mod/hvp/share.php', array('id' => $id)));
 $PAGE->set_title(format_string($cm->name));
 $PAGE->set_heading($course->fullname);
 
-// Load JavaScript and styles
+// Load JavaScript and styles.
 $PAGE->requires->js(new \moodle_url(\mod_hvp\view_assets::getsiteroot() . '/mod/hvp/library/js/h5p-hub-sharing.js'), true);
 foreach (\H5PCore::$styles as $style) {
     $PAGE->requires->css(new \moodle_url(\mod_hvp\view_assets::getsiteroot() . "/mod/hvp/library/{$style}"));
diff --git a/view.php b/view.php
index 09b8c1168260437d3695bb8609d6ff78ee0d2d9c..cadb75ef0e9219f9b3ea09241eaadf619e689244 100644
--- a/view.php
+++ b/view.php
@@ -78,7 +78,7 @@ $huboptionsdata = array(
   'isshared' => $isshared
 );
 
-// Update Hub status for content before printing out messages
+// Update Hub status for content before printing out messages.
 if ($hashub && $isshared) {
     $newstate = hvp_update_hub_status($content);
     $synced = $newstate !== false ? $newstate : intval($content['synced']);