Fixed some Analysis warnings, fixed minor memory leak