Minor changes

Fixed horrible memory leaks caused in last commit