Merge fixes from the upstream dannvix branch