More error handling added.