added arrow key functionality to gallery, fixed bugs