Bug fixes and adjustments