Compile fixes, implement exists test for database;