portability improvements

Reviewer: @rlane