Caps win despite sloppy game