Refactor gerrit stuff in api