Rename states to hopefully be clearer; add more comments.