Improved monitor script.