Set refactor, and code tidying