Fix Locals analysis

Nested Functions support was clumsy, this should fix #186.