Fixes for linux and better error handling