Lots of changes!

* Formatting
* Return :error tuple, don't raise exception
* Added some tests for error conditions
* Result is now number or error tuple