Rafactoring and clean up