Handle cases where messages['messages'] is None (python 2.6)