Improve the monitoring setup script and fix bugs in the monitoring config.