Refactor and move around files and extract separate module