Write data to DB only when connection is available.
Remove unneeded library.