Move database functions to dbtools directory
Fix handling of spacey directory paths