fix compile and runtime errors