Fix and refactor diagonal mapper.