Refactor Database connection. Added Create Index and Balance.