bug fixes and working scripts