Cleaned up the code

Also some fixes to the node dragging and positioning.