Significant restructuring of unlock_runtime.py