mka: Reorganize loops in number of KaY functions