Tweaked response handling to avoid serialising a null return value.