critical bug fixes and some additions