This code confused the hell out of me today. Split _get_new_device_messages into its two (unrelated) parts.