small fixes to avoid NullPointerException