Fix for #57

As I mentioned in #57 I found a solution and decided to fork and send this pull request.

Sorry for having the trailing whitespace removed in the comments as well. That was done automatically by the IntelliJ code formatter.