Small fix
More fixes, better stopping condition