Corrections for CPU version (reverted from commit 8e5473d49bf476c15cfa7e8d1ff19f6c33af0358)