big refactoring and cleanup
also added predicate operations and fixed setting predicate values