Fixed some bugs after initial test