Refactor cuss management into a separate class.
This also improves database connection handling by checking to
ensure that the connection is up before every query.