added in checks to ensure nodes are of the correct types.
added support for Not operator.  Did minor refactoring.