Cleaned up error handling, fixes #8; documentation through API, fixes #9