refactor and generally clean things up