Edits to control the amount of data returned by function calls and make the script more readable.