Fix NPE. Close #428.