add requirejs support
cleanup and adds caching
use a stringbuilder
extract the Pattern
reformat
cleanup return
synchronized and logging and final