lots of improvements from josch
merge fix