Cleaning up the code, improving error handling and performing a minor optimization