Changed the way parameters to mainsearch are held and used