Refactored function lexical management

Signed-off-by: Grégory PLANCHAT <g.planchat@gmail.com>