[fix] moved array variables to local context to fix memory leaks