Refactored the encodeMaps function slightly.

+ FMT