Refactor and cleaning