some type improvements - sadly had to include some boiler-plate