refactor, refactor, refactor and small improvements