Merge changes from 1.0.x branch (patch from Simon Legner attached to bug 1129).
Merge origin/master