Small general refactoring of localsearch.