1. Code cleanup and getting the logical tree basics in place