use some structs to get rid of nasty type hacks