Refactoring code structures, refines ideas