further cleanup and var fixing