improved termination checks, addresses #2