fixed memory leaks and buffer overflows
little refactoring of SCRAM implementation