Fixed apparent redundancy in handling 'mapping template', added trim() calls

Change-Id: I04b46be355c692c5e3115ebfb0fea059e2adfe3f