BSD/GNU compatibility fixes