Various Bug Fixes and Improvements