Clean up code and use dnode