Refactored for easier config with JSON file.