Fixed NPE

References #590