better chain handling - reference #844