Linux compatibility and cleanup