Bugfix: wrong handling of large number of raft layers. #2041