I used Kyle's suggestion of using IFERROR() to help clean up the formulae and keep them readable.
It seems like newer versions of Excel have an IFNA() function, but that's currently unavailable in Google Sheets. Hopefully it will be implemented in the future.
It also goes without saying that IFERROR() will swallow any errors thrown, so be careful if your data requires special error handling.