improved stack trace output / bug fixes; fixed compiler error on some Windows systems with SetThreadErrorMode call