Todo update and some refactoring