Added features from mschobers diff. Fixes #2