more of the huge boring refactor
a few changes to help compileing along