refactor a bunch of junk for transition to cjsx