Improved monitoring script.