minor bug fixes and polishing