Fix some dependencies; share more code