Improved relval_machine.py