Make DnD better and some code refactoring