refactor

this pull requests contains the code for a considerable refactor that was underwent.