Changed the variable names to be more consistent
Merging small changes from Omar's commit
More small tweaks