Loads of code/doc cleanup