Improve error handling

for checked cast and csv loader
Add installreformathook