Added better protection around null arguments and fixed a possible
initialization bug.