Fixed message insertion in database