Lots of documentation and small fixes to generator