upmonitor.py: clean up messy code, allow changing data_dir on the fly