Fixed some minor bugs in the previous commit