various changes, seperated common elements into templates