Some database related fixes from redheadedrod

These should squash a few issues, such as the group permissions not deleted
bug.
Merge pull request #22 from geekwright/master

Some database related fixes from redheadedrod