Fixed compiler errors - WARNING: contains serious memory corruption bugs