More comments, also uses a template now

Memory type can now be specified by template. Also, more comments.