massive code cleanup

- get rid of unchecked cast warnings
- remove obsolete null checks
- simplify expression generation
- fix visibility issues
- add missing getters
- remove deprecated classes
- remove templates