several bug fixes.