Refactor and reorganize code base #10