Partly reverted changes of 3118f395a2e7d9845e663b1b6071a4b95be74c7f and
added some more variables to improve inlining