Fixing compiler errors and warnings