few bug fixes and corrected some output