Refactor contest permission system and add javadoc