fix some bugs for levels that are not the exponentiation of 2