First round of bug fixes, see README