diff --git a/lib/classes/Avatar.class.php b/lib/classes/Avatar.class.php
index ac074d63cdd01dd24b474973822cf824fad74659..b6165bd89befe8945f7cc54e2e13a8b8fe16c07f 100644
--- a/lib/classes/Avatar.class.php
+++ b/lib/classes/Avatar.class.php
@@ -118,7 +118,9 @@ class Avatar {
 
     public function getCustomAvatarUrl($size, $ext = 'png')
     {
-        $retina = $GLOBALS['auth']->auth['devicePixelRatio'] > 1.2;
+        $retina = isset($GLOBALS['auth']->auth['devicePixelRatio'])
+                ? $GLOBALS['auth']->auth['devicePixelRatio'] > 1.2
+                : false;
         $size = $retina && file_exists($this->getCustomAvatarPath($size, 'png', true))
               ? $size."@2x"
               : $size;
diff --git a/lib/classes/MyRealmModel.php b/lib/classes/MyRealmModel.php
index 9f62b427cb2e12faf682fb0dc69e6f2ae290385c..878b4a267cdf80ba83150d223a7ac82d811c9e85 100644
--- a/lib/classes/MyRealmModel.php
+++ b/lib/classes/MyRealmModel.php
@@ -308,8 +308,8 @@ class MyRealmModel
         foreach ($courses as $index => $course) {
             // export object to array for simple handling
             $_course = $course->toArray($param_array);
-            $_course['start_semester'] = $course->start_semester->name;
-            $_course['end_semester']   = $course->end_semester->name;
+            $_course['start_semester'] = $course->start_semester ? $course->start_semester->name : null;
+            $_course['end_semester']   = $course->end_semester ? $course->end_semester->name : null;
             $_course['sem_class']      = $course->getSemClass();
             $_course['obj_type']       = 'sem';
 
diff --git a/lib/navigation/Navigation.php b/lib/navigation/Navigation.php
index ab4a8fe973689a6d860e548f979f30ebf443c718..149210849f9cefa0259486f990d636a6f9c10602 100644
--- a/lib/navigation/Navigation.php
+++ b/lib/navigation/Navigation.php
@@ -514,8 +514,11 @@ class Navigation implements IteratorAggregate
      */
     public function insertSubNavigation($name, Navigation $navigation, $where)
     {
+        $subnav = [];
+
+        $done = false;
         foreach ($this->getSubNavigation() as $key => $nav) {
-            if ($key == $where) {
+            if ($key === $where) {
                 $subnav[$name] = $navigation;
                 $done = true;
             }