Work done towards further cythonising. Also some work to update the command line script so tempdir is unique