Simplification of scripts, bug fixes