Updated to include image uploading and better error handling.