Refactored queued tracking

Better code in queued tracking. Some performance tweaks in core
(eg Piwik\Piwik and PluginSettings), better tests and more