refactoring code, removing cruft, adding documentation, fixing a few smaller bugs