Adding our changes into new base version from upstream
Updating to latest version, adding helper functions for use in other parts of our moodle plugins