Heroku env detection and code cleanup.

Fixed
  - Server init script
  - Config management
  - Database management