Improving the performance in critical code sections