Changed messages, now closes connection to db