Merged logic for Linux and OS/X