Restructuring the code. Still broken.