Big refactoring of lots of stuff, general mahara goodness