Move 'handle_args' to near end of script.
Move ami reduction script inside ami module.