add controller to build
check for cxxtools and tntdb at configure time
cleanup database access a little