Better performance and other fixes