Bug fixes
Optimize