Is this something we should always be able to return? (not looked at your entire code yet, but if it's a variable resolution grid, should you be returning bdx and bdy when they could be BMDI? (I'm probably not understanding the complete picture yet)