Factorize memory allocation code
Change case of log functions