factored out Region class
fixes to previous commit, cleanup