The only thing that jumps out at me is the modification of PATH.
The path to VIM should be first on the path list, not added at the tail.
Change the order of that assignment.
Could you be a bit more specific than: "works incorrectly" please?
It is very hard to follow what the trouble is without the specifics.