WIP: Improved error handling