Fix error handling
Add better unicode handling