Minor performance tweaks and readability changes.