Updated: added -x option and better time interval handling.