Some refactoring. Medium images now increases download counter too.