Refactor and document subject scheme related code