proper exit code and fix Python 3 support