clean-up the code, return 1 on error, fix README.md