Fixed changes overwritten by copy/paste and reviewed new code.

Fixed spacing and parentheses, mostly.