Account for possibly missing data structures

Also includes small formatting changes.