Finish AppLock function (still have TODOs -- optimization)