faster and more thorough integrity checking, added code to print tree