Avoid `eval` and fix logic errors.

Similar to #4, with the added benefit of fewer `eval` calls.