Switched to new representation with the values higher up in the tree
Rearranged the conditionals to be more efficient