WIP codebase - #13 and few cleanup and structing code