Fixed compilation errors and testing problems