Now logging works

Also reindented all the code :-(
Logging works!
Merge pull request #2 from mdz/master

Getting there...