some further minor cleanup of set.rb

mostly moved stuff around to put the "most public" API at the top and tighten a bit.