little cleanup of the code and changes in image handling

cleared some not needed code lines, changed the handling in functions
from global to function inputs, build in new image handling (when image
was found and then connection lost old image will be displayed till new
image is found.)