Lots of improvements and cleanup.