Fix bug in ShaMap. Still needs tests