Code Cleanup

This PR removes dead code, standardizes style, and splits tests into
smaller units.