Fixes #156 and other minor issue with galleries