minor algorithmic improvements