Refactor, remove dead code