a bit of refactoring, comments, and dead code removal (with whit).