Fixed a null pointer reference error, which at the same time streamlined the process of returning the map if it didn't need to be trimmed.