Python V1

Changed from bash to Python. Refactored some code.