Based off b80915eb99 and compacted into a single commit so that it will fit on the uni git server
b80915eb99