generalize KXK rule (6328162)
revert stack size optimization