layout optimization and fixed null ref on timeout