moved here some misc code from tasktracker
some improvements
some errors fixed