Fix problems with galleries, and also fix file downloading.