Only minor changes and simplifications

Hi,

Your project looks really interesting!

I read through the code with no particular goals and made the following changes. Accept or reject them at will:

* Removed a few empty lines. Tried to group the lines in a logical way.
* Changed a few unneccessary if-checks at then end of functions to just return the values/errors.
* Placed the types on the top, then the variable declarations, then the functions.

Some of these are a matter of taste, but I especially think the removal of unneccesary if checks at the end of functions may be considered good style.

Best regards,
Alexander Rødseth