Some refactoring, Database utility class