found a bunch of potential unhandled errors and handled them

they may or may not be necessary and might fix the leak, not extensively tested... dont see the harm in merging tho...