move some code around, also update some interfaces