Fix broken dependency and make code nicer