Added support for a couple new data types

I also used templates in some locations to reduce duplication of code, and inlined a function that was showing up as a hotspot when profiling.