Will require additional work for 3.5 (shouldn't blindly remove perm_lock without asking the user; update comments; add standard headers) but I don't want to lose this code.