Major bug fixes. Still buggy, but largely working!