Fix message for reference error
Raise correct reference or type error
Use switch statement
Use rb_ary_entry