TODODONE: Refactor some code