Sam improvements

It's all in the commit titles and code.