apntool and ApnDatabase

// FREEBIE
Avoid leaking cursor.

// FREEBIE

Closes #1838