some null checks. issues #57 and #58