some cleanup, move code to python file