New version of the script:
 - add functions
 - add rollback and cleanup support
 - better option parsing
 - cleanup