made autoscroll work better with images and code cleanup