Ported last fixes into SLE-12 branch

The code was already reviewed. See PR#259 and PR#261