factorize some code, and code for literals and tables nodes