Refactoring memory_alloc & coding conventions