typo fixed, slight code cleanup
Added fixes from lathan's patch, markdown things discarded.