(partial) code changes per PR comments