Redone logging, fixed upload logic

Syncing with upstream