fixed NPE (closes #501)