Code organization

And preparation for future improvements