Add more tree code and replace some booleans with enums.