Add bool, more ops, refactor utils and tree structure.