Minor code cleanup in chain.js