some bug fixes + script analyzer