A bunch of cleanup and documentation