more localization and variable removal