Implement upload
Fix various small bugs