check more malloc return values
more cleanup stuff
switched to wrapped malloc for OOM checks
more verbose error messages with details
etc