Fixed some commments and organized code a bit. No logic changes.