cleaned up some code. at some point I need to test all this shit.