Refactoring and cleanup

- Updated ProgVarLoc and ProgVar.
- Updated some examples.
- Work-in-progress, some parts won't compile.