Rebased mbajur's branch on latest master, resolved conflicts.

Wot it says on the tin.