Lock system is based on functions in functions.inc.
It should be moved to a Lock class which offers static methods to manipulate locks, and returns locks as objects instead of arrays.