Simplify template a bit, add a bit more documentation.