Several bug fixes.