Refactor main code into a main method. Pass options as parameters.