Some important fixes for gallery