Refactor a bunch of funcs