Make script more readable
Ensure that all transaction output has the same number of columns
Remove unnecessary SQL
Code efficiency improvements