Fixed the way chains are handled. They work now.
Merge pull request #9 from TisButMe/improve-chains-handling

Improve chains handling