Improved StackTrace with tests

Also other minor improvements