bug fixes, improve performance