Refactor of variable names/code layout