Corrected mistakes related to scaling and variable handling