Cleanup and fix for linux