fixed some encoding issues and made exception handling a bit more informative