Osheroff/fix stack overflow