fixed type in 'optional'
added matching for uppercase on line 325.  Was missing parts of ids.