Improved dangling rule handling. Closes #31, closes #32.