fixed a crash on invalid locations
fixed a crash

get rid of HandleTopLevelDecl; use the same routine
for collecting var info and rewriting