Refactor some stuff