Rename variables, add quality info, and re-organize functions.