fixed rare error (how can that even happen?)
improved error logging