Merge changes Id1d8ffb8,I20a6396d

* changes:
  Fix broken foreach loop
  Reduce stack usage in ckati