Added UIImage extensions, refactored code