Some work on the mapper module. Will be moved to a separate repository.