Went through code, adding debug output. Seems to be working now, let's test