bug fixes and other improvments