Library injector refactoring

This is a complex pull-request, but I think it can be useful to project.
First, I've fixed compilation with Microsoft compiler.
I have almost fixed compilation of the whole Prismatic project with MSVS, so later I can send you patch if you don't mind.
As far as I know it is not a default compiler for this project, but the code is good enough to compile and run using this compiler.
After that, I've made some refactoring to make code simpler. Also I don't like compiler warnings, so I tried to fix most of them.
Hope it can help.