Added exception handling to allow the unit to never crash (probably). Also tweaked the image processing