adding malloc memory system and some build fixes