Improve totient algorithm, and comments all around