Make improvements to the script and add documentation