Merge pull request #3 from marado/master

A bunch of bugfixes. Thanks.
forgotten commit