Fixed performance problem with Database operations