Should fix all encoding errors. I also fixed some error reporting.