Cleanup, hunting bugs

I think I’ve found the pointer overflow error. need to test.