Now compiles (still needs testing)