Updated comments and added additional exception checking code