Bug fixes

Some bug fixes