refactoring moodle/solib for clean code base