Add missing imports, undefined variable fix