refactorings and fixes for linux