Fixed much of code so it will comply with new definition of distribution_real and searchspace