mapgenerate improvement and other small fix.