Several unfiex changes in galleries functions

Still working on it
Gallery Pagination

Now its working properly, but i should double check and do some test.