Refactoring ocg.py