still working on rewrite, fixing basic then/or/gate functionality, added several tests