cleaned up code; added explanations to README.md