remove leaks from stack
traverse the other way
fix id regex, thanks @bwoebi