Several fixes (race condition, thread sleep)

- Moving to .NET 4.5
- Avoiding Thread.Sleep
- Fixing race condition