Got the thing to compile, still some type inference issues.