Put common functions into each script as required.
Added examples
Added some file checking.