almost done with the initial port.. the switch cases for the various types is hideous