Added better support for python2.6
Added tail implementation