added some python refactorings