Added 'trace' monad to get a stack trace, various tweaks