complete rewrite of the memory png-template