inner modules and more abstraction
merge and fixes