Simplified code and fixed decrement bug
Added revoke RS access function