Debug flag added
Fix dangling forward/backward references
Test for removing from tail