Many changes to get this to compile, some temporary.