Added handling of status messages, still debugging it.