(Hopefully) improved error handling