Code restructure

Added .hpp files and moved templated class implementation from .h to .hpp files. Also added explicit template instantiations in the .cpp files. Removed templates from a couple of classes where templates weren't needed.