Fixes and cleanups for the least-squares scorer

This has a few fixes and cleanups for the least-squares item scorer. See commit messages for details.