Seeming reasonably stable
Slightly cleaner factoring
Removed some debug logging