Bug fix for G(r)

Also the boundary conditions are implemented in a more organized way.