redesing and some refactorings.