Various bug Fixes