Fixed small but significant bugs from previous commit.