Some cleanup and added ability to specify settings via ENV var.