Code reorganisation.

TODO: resolve names in all modules + make the project compile with native code.