Fix for ticket 1543: BIM index out of bounds error
Fix for ticket #1543, adding a check to not process references were the index is out of range (reference frame is out of range of the sequence)
Also fixes an copy-paste error in xCheckParameter for the BIM related macro