Variable name changes and minor fixes