Refactored into python package