Changed memory check to ensure it doesn't go over the limit, but doesn't adjust unless it really has to.