Python3 compatible

Add Python 3 compatability and move some helpers methods to separate file