Fixed gallery Active field and small refactoring