Refactor resources.py and representations.py