Merge refactor

Benjamin Mako Hill || Want to submit a patch?