Integrate changes from Sebastiaan Klippert