attempt to fix Xf bug (doesn't work, will try again tomorrow)
live up to promise of O(lg n) worst case memory