New Logic. Errors need to be fixed.
Fixed merging problems