Refactors __main__ into seperate tool module.