Fix null pointer exception

pageBuilder method attempted to get the length of null arrays before
they were initialized; size now defaults to 0 when arrays are null.