Some refactor and go fmt