Addressed PR comments: fixed some documentation and DRY'd up the error checking