Refactor a few things