many changes, mostly fixing compilation errors