Small bug fix in chain.collapse
Support for apply for chains.