Cleanup and refactor of expression.py.