Mainly housekeeping

- Fixing variable names
- Code cleanup