Improved market generation, misc fixes and improvements