use ast_calloc instead of calloc, and do a little bit of tweaking on the code formatting