Minor updates and added more error handling