Why not use featureMap[f] instead of layer.getFeatureWithUid(f) here anyway? I am aware that I must be missing something here :)