Fix stack overflow
Various fixes to make this actually work now