typos corrected, bug fixes