Add general ledger database class.

Also refactored gl_db program.