Added image type check

Plus other very minor changes.