I have no idea how this code works, but don't touch it, me
Gallery stuff