bug fixes and a new script