Updated to make more flexible for production deployment.