Major re-write (Though still not working correctly!)
Authored by: philsp 2016-04-18
Parent: [r3922]
Child: [r3924]