txdb-related fixes and refactoring