Bug fixes and performance boost