Refactor code to prepare for multiple keys per mapper support. Work in progress