* Throw more appropriate exceptions
* Simplify detection logic
Merge pull request #28 from jayzeng/refactor/exception

Refactor/exception