Error handling and WMTS bug fixes