Lots of cleanup and bugfixing, adding SetMap() util class