Fix scope tracking, add a whole bunch of export stuff