a couple of fixes for Moodle 2.5

These changes apply to Moodle 2.5 branch. We need to make a branch for Moodle 2.4 before these changes.