Move template class specialization in header

also reorganize headers.