Cleaned up code according to code review.