Refactor project structure. Introduce helpers, and cleanup code a bit