This is ugly and at the time of writing #43, I knew no better way to do this. Some discussion on the topic can be found here.