Fix possible NPE.
Update 3rd party libraries.
Fix erroneous caching method (createOrUpdate led to creating duplicates with a newly generated ID).
Avoid NPE, IllegalStateExceptions and ArrayIndexOutOfBoundsExceptions at various locations.