Some bugs fixed

Some still remaining