Clean-up hash lookup and avoid local undef var