Added the type annotation to executor.
Fixed resource leak.