Basic fixes to make it compile

I have no idea if it works, but at least it compiles now.  Check for
comments labeled ZB for questions.