Fixed some bugs in last commit.