A couple bugfixes (forgot to remove require "pry" line) and some slight
refactors.

bugfixes and some slight refactors

refactor and bugfixes