main data structures are done, but still lots of TODOs...