Refactored for supporting dev/production settings.