fix some todos
fix quite a few bugs and fix some todos