Fixed some minor bugs found