Oops, my fault. I'll add local to all vars since they need not to be exportable outside this function.