Refactor/reorganize some of the code base