improved memory management for functional engine