Thank you, this is very helpful.
Only add-on comment on your last sentence ... I deleted the "optimize" folder but then Kibana would not start giving me the following (main) error:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
I managed to deal with it by following this post and by increasing the heap memory:
NODE_OPTIONS="--max-old-space-size=4096" /usr/share/kibana/bin/kibana
This way it managed to get through the optimizations and rebuild the 'optimize' directory.