Fixes to make the code build (it is still untested)