Updated comments and more refactoring.