many bug fixes & improvements