bug fixes, plus few improvements