FIX: added try/finally to make sure locks are ALWAYS released
FIX?: sometimes the string substitution crashes, and no idea why. This
is a small protection.