Move together util functions and clean license
Code and fule reorganization to improve modularity