more generic error handling,  respect arrays when replacing links with includes

fixes #6