refactored scripts, gallery layout complete