Updated, refactored code.