Big refactoring

Making first step towards having different packages to handle logic