one memory leak fix and several compiler warnings/analysis errors