Bug Fixes and Optimization