Tweaked rewrite, fixed small bug.