Restructured some of the python code

#16