Fix bugs (noticed in real tests)