Fix coverage and simplify code.