I have got it compiling and working.
There is an issue excepion propagation that needs to be resolved.
I have added many printf debugs
I have broken the original code formatting for my own clarity.