Refactored to use DatabaseAdapter.