implements #397
implements #448
fixes #411