Refactor __main__ module