Huge changes too many to list.

I'll endevour to things up into smaller commits in the future ;)