Fixed some small bugs upon code review.