fixed several memory leaks, working on nondeterminism through quotes