restored compatibility with MSVC, fixed some serious bugs