Replace crappy code with abstract class
Conditional thread safe database execute