Add file sharing function and fix some bugs