dm: some bug fixes