Refactored and cleaned.