Stack overflow fix