Better error handling and stability (no NPEs!)