Merge pull request #133 from bastih/master

A bunch of fixes and improvements