Using promises, and encapsulating the DB better.

More concise function notation.
Added Q promises
DB is no longer called directly.