Clean-ups and refactoring