Cleaned; documented more thoroughly; added ideas for testing