Split out the easier libraries from lib/common
Now that I've made a start (see legacy/trac#26442 (moved)) it's time to split the rest of the common directory.
Some of the splitting will require disentangling individual files, but some is fairly easy. I'll do the easy part first.