Refactored and removed unused code.