Added automatic stack print, initial locking, fix statistics bug