Refactored apply-effects, a lot cleaner now.
Assorted formatting.