Add several performance tweaks, bug fixes.