Use a sensible timeout when waiting for injection thread. Fix #171
MinGW32 compile fixes.