some local var name changes, added some minor stuff