Cleaned up some of the code

I need to go bug hunting soon