Made references smoother, got rid of potential memory leak