Refactored to use module pattern.