fix specs and various logic issues