Fix bug with generating head and tail functions. Update builtin resize function