I've been thinking of closing this down and doing a revamp of the whole thing. These access check functions are rather messy and there's copy-paste everywhere, it could really use a cleanup (and comments to go with it).