Fixed bug in adding messages to the local database