added callback support; become python 3 friendly