refactor to be non-terrible
get refactor working, add --debug cli option