Fix code to pass all tests. Refine dependencies.