Coderefactoring and done some TODOs