Restructured the code. Still broken, but now less so.