Update master.py

Changed handling of error records to be more readable. Did some basic debugging.