Fix gcc 4.9 build errors related to templates (cc: #48)