Implement a smarter engine for non-lisp modes.

Now should really fix #7.