added functions to tseries.py and util.py