Fixing constructor calls that throws NullPointerException