Had a chat with Adam about this, it would be cleaner to move the code that figures out $lock_timeout into this function.