Refactor

This PR refactors the complete setup into several files, including some namespace renamings and polishing of the overall architecture.

@theneikos: Please review. I used your commits.