I think I got this working properly now.