fixed "market" variable bug (and some others)