handle empty galleries more elegantly - fixes #270