Latest DSystem
Adapted code to compile with the latest DSystem (almost compiles under OSX)