Refactoring pycompilation

Moving over some functinoality left behind...