cleaned up code. fixed bigger bugs