More work on coffee generator

Also optimized code