database-internal: Few database fixes
threads: Implement threads and several bug fixes

Implement timer and looper threads and bugfixes.

Signed-off-by: Michal Novotny <mignov@gmail.com>
threads: Rename DPRINTF space