some better error handling, fixes