lockService, better redirects

stops processing php immediately if a redirect is needed
menu_functions, cleaning up

removing white space, adding comment