fix a few bugs with last commit
Fix slight indentation issue
Indentation madness
use dlist for slightly better performance, but more for semantic reasons (queue, not stack)