Improve type logic checking. Don't assume the 'result' key.