Update Gallery to BS3

Update the gallery to Bootstrap 3 RC1 and move the remaining gallery functions and filters to ```lib/gallery.php```.