Fixed compilation, started on db retriver. Wrote some tests.