Moved to .env and fixed old var name in pre_start

As per my previous request, but without misc unnecessary commits.