Refactoring and cleanup

- Added missing files.
- Work-in-progress, some parts won't compile.