refactor (more needed), add useful functions for dealing with clauses