Move all code to headers

This should solve the issue of template being removed and unavailable
from the build. Though the code is still separated.