Fix permissions
Move database connection to a global namespace