NPE bug fix related to copying