Fixed bug in which a while loop was inadvertantly comparing something to nil.