changed method for granting db privs and did some tidy up