doesn't assume first location is away
replaces duplicate entries in analysis tables
don't need postloc yet, commented out
removed unnecessary if statemnts due to SQL simplification