More fixes to logic.
Bugs and a recurring seg-fault left to fix