Refactor some minor bits