everything compiles and fixed various bugs