The infinite loop was not stopped by an exit, but the previous mechanism was different. Fixed.
Separated different kinds/sets of database access functions #29