Fix NPE bug around initialization and code cleanup