Fixing some bugs in the last commit