Refactoring and Python styling compliance