Added some behavior and made some refactorings