$L^2$ Betti numbers and kernels of maps to $\mathbb Z$