Bugfixes, memory and performance improvements

The literal trail is now correctly stored backwards to allow quick
adding to the list and removal from the end.  An bug where
findLastAssertedLiteral was always returning the first asserted literal
was fixed.