Fixed bugs found when run