Fixed some bugs from previous commit.