refactored legion opt functions to be more plugin friendly

It seems that I've managed not to break it (at least simple legion setups still works just fine), but please review and post any changes you want.

Also I've noticed that in original opt function ```char *legion``` is not always freed at the end, I saw only one comment in ```uwsgi_opt_legion_scroll()``` that it should not be freed. Please verify it we free it every time we should.

As always naming will probably need refactoring, just let me know.