Add better error reporting and fix typo