Lots of cleanup, documentation, db functionality.