Use string representation of object when formatting error messages
Refactor chains into separate file