Portability fixes for Linux and headless sessions.