Some refactor/cleanup