fix initialization order (and use one instruction per line...)
add more assertions to detect failures as soon as possible
bug fix: don't dereference a NULL pointer
bug fix: don't dereference a NULL pointer
add assert()s