Code refactoring due Moodle 2.6 changes