merge @bertschneider improvements into my branch