Support running without database.yml

Added support for running with only DATABASE_URL for 12 factor compliance.

Also refactored the database configuration code.