let rec simplifications and optimizations

Still only currenly supports lambda binding on let rec statements, but the plan is to get other bindings going at some stage.

Fair bit of code changed here.

Still have some ideas about more optimizations, but seems like a reasonable place to cut it.

I'll merge this during the week if no one has any issues.