Some refactor work