Bug fixes, some changes