Make can_simplify and get_result more robust.
Fixes #107.