Clean-up and refactor