Fixed bug in legacy.py, causing pickle tests to fail