Hacky fix for gallery navigation bug