Refactored contests code