Cleaning

Cleaned up some of the code. Got the permission check kind of working,
it at least runs in the background now, but it's still broken, it's
commented out for now.