Removed almost global std
Fixed buffers getting deleted