various bug fixes.