modifying the code to be safe for DLL exports
still some more modifications
some more changes
Modifying the code to be safe for DLL exports