Refactoring and addressing errors.