Fix scoping and add more defaults