greatly expanded methods and fixed several typos.