Spelling correction, added comments, cleaned up error returns.