Remove extraneous code, refactor