diff --git a/lib/grade/grade_category.php b/lib/grade/grade_category.php
index e8d07552362..c62dae6f83e 100644
--- a/lib/grade/grade_category.php
+++ b/lib/grade/grade_category.php
@@ -168,7 +168,7 @@ class grade_category extends grade_object {
      * @return int The depth of this category (2 means there is one parent)
      * @static
      */
-    public function build_path($grade_category) {
+    public static function build_path($grade_category) {
         global $DB;
 
         if (empty($grade_category->parent)) {
@@ -520,7 +520,7 @@ class grade_category extends grade_object {
      * @param array  $items Grade items
      * @param array  $grade_values Array of grade values
      * @param object $oldgrade Old grade
-     * @param bool   $excluded Excluded
+     * @param array  $excluded Excluded
      *
      * @return boolean (just plain return;)
      * @todo Document correctly
@@ -819,11 +819,11 @@ class grade_category extends grade_object {
     /**
      * internal function for category grades summing
      *
-     * @param grade_item &$grade The grade item
+     * @param grade_grade &$grade The grade item
      * @param float      $oldfinalgrade Old Final grade?
      * @param array      $items Grade items
      * @param array      $grade_values Grade values
-     * @param bool       $excluded Excluded
+     * @param array      $excluded Excluded
      *
      * @return boolean (just plain return;)
      */
@@ -1196,7 +1196,7 @@ class grade_category extends grade_object {
      *
      * @return array
      */
-    private function _get_children_recursion($category) {
+    private static function _get_children_recursion($category) {
 
         $children_array = array();
         foreach ($category->children as $sortorder=>$child) {
@@ -1437,7 +1437,7 @@ class grade_category extends grade_object {
      * @return object grade_category instance for course grade
      * @static
      */
-    public function fetch_course_category($courseid) {
+    public static function fetch_course_category($courseid) {
         if (empty($courseid)) {
             debugging('Missing course id!');
             return false;
diff --git a/lib/grade/grade_grade.php b/lib/grade/grade_grade.php
index 4bbc427b2dc..1b710aefc02 100644
--- a/lib/grade/grade_grade.php
+++ b/lib/grade/grade_grade.php
@@ -159,7 +159,7 @@ class grade_grade extends grade_object {
      * @param bool $include_missing include grades that do not exist yet
      * @return array userid=>grade_grade array
      */
-    public function fetch_users_grades($grade_item, $userids, $include_missing=true) {
+    public static function fetch_users_grades($grade_item, $userids, $include_missing=true) {
         global $DB;
 
         // hmm, there might be a problem with length of sql query
diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php
index 48f990322fa..47b11939020 100644
--- a/lib/grade/grade_item.php
+++ b/lib/grade/grade_item.php
@@ -438,7 +438,6 @@ class grade_item extends grade_object {
                 $this->idnumber = $idnumber;
                 return $this->update();
             }
-            return false;
 
         } else {
             $this->idnumber = $idnumber;
@@ -944,7 +943,7 @@ class grade_item extends grade_object {
      * @param int $courseid
      * @return course item object
      */
-    public function fetch_course_item($courseid) {
+    public static function fetch_course_item($courseid) {
         if ($course_item = grade_item::fetch(array('courseid'=>$courseid, 'itemtype'=>'course'))) {
             return $course_item;
         }
diff --git a/lib/grade/grade_object.php b/lib/grade/grade_object.php
index cf1981d20d1..62ea77014f0 100644
--- a/lib/grade/grade_object.php
+++ b/lib/grade/grade_object.php
@@ -101,7 +101,7 @@ abstract class grade_object {
     public function load_optional_fields() {
         global $DB;
         foreach ($this->optional_fields as $field=>$default) {
-            if (array_key_exists($field, $this)) {
+            if (property_exists($this, $field)) {
                 continue;
             }
             if (empty($this->id)) {