Fixed some silly bugs and cleaned up