Tomasz rosiek master

Merge tomasz-rosiek improvements plus a few fixes