Implemented chat database save and little clean up