adding support for python3 and python2, added functions for easier caching