Rewrite nvram variable handling code