Added support for Python 3 on OSX and fix cleanup of environment after prompt definition