Fixed issues based on Andrew's comments.