added some comments on problems, and some optional logging