refactored database connector: now the channel functionality is encapsulated in a closure. Cleaned constructor of database object.