add missing vars and fix bugs