fomosto: fixed problems occurring when grid size not multiple of spacing