gallery now attaches and detaches correcly for new images