fixed remaining issues from latest merge with upstream.