WIP: fix CJ media type
WIP: improve CJ template parsing and error handling