Add better error handling, return codes
Merge branch 'master' into error_handling