Fixed some bugs in code