split out bits of core for badges, tags, enrolment

Also moved a couple of things to do with forms and tables,
and deleted some unecessary table related things.