fixed uninitialised memory bugs