Switch Object.locks from a dict to an object

Access a given lock by, e.g. self.locks.take instead of self.locks["take"]. The
performance is the same, but it's semantically more correct.