move some panel code over