Use new vcs API, improve code style to be less nested.