Refctoring and cleanup

- Split the compile-time configuration options into separate files.
Refactoring and cleanup