fixed a few bugs and cleaned up stuff