Fix warning about uninitialised variable and add assert