Code clean up and replacing environmental variables with local ones