improved installation scripts, fixed agent-stopping bugs and updated the locking protocol