Rename variable and function names

In an effort to simplify code logic rename variables and function.
Removed unused variable "old".
Add configuration variables.

Made few hard coded values as configurable variables