Partial fixes to logic issues