misc portability patches