Main: avoid stack space explosion and use local bindings instead