Commented, some refactoring