Bug fixes

some bug fixes