Fixes shutdown issues and compilation issues on linux