added in most of the changes suggested from code review