Attempt some optimizations for #215.

The most notable change being then implementation of firstOrCreate()