Refactored piwik code and added moot support