Updated to match Tom's latest changes