Initial attempt at porting the code

Does not compile successfully yet