Finished first version of gallery code.