Fixed all compilation errors and warnings