Various clean up and refactoring

This commit adds various type specs, cleans up indentation/spacing, and
improves the clarity of the return value kofta:produce/3.
Make return value of kofta:fetch/3 less opaque