I definitely don't like how I do this, do you see a better way? (see my commit message for some information about things are done the way they are)