refactor and clean up a bunch of stuff.