fix some problems handling large vectors reported in PR6230