Fixed parse errors, typos, and bad selectors. Also reduced code repetition.