small improvements and code review of Galleries.controller.php