Small changes to improve portability and stabilize compilation