Initial porting to python