cg portability fixes