Fixed exception handling in engine implementation.