Some bug fixes

Strange bugs I found, but fix it