Auugh, too tired too inspect ATM. I'll look at it later today maybe, but the only thing I can really say is that you should name your variables (eg. def loc 987), or at least write a small comment here and there so we know what's going on. My DB is still not running, so I'm just going to scan for plain error...