cleaned up some old code and fixed a couple minor bugs