Updated to Tom's latest changes