dx/dy can be negative, we should still add them
Clean up some formatting
Add descriptive comments