Changed to memset to make code look a bit simpler
Skipping buggy code for now. Will be looked at some time later