More or less fixed (though still NOT compiling)