Various changes to help portability