move registration code to corresponding cpp files.
Merge pull request #1270 from Yangqing/dev

Give back to layer what is layer's, and to factory what is factory's