add mem()
use mem() instead of malloc()
adjust for mem()
add copyright note