Numbertree solution now correct. Also added some cleanup.