Cleaned up spacing, added comments, and fixed api error message.